package com.jvyou.mybatis.demo.factory;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.jvyou.mybatis.datasource.JvyouDataSourceFactory;

import javax.sql.DataSource;
import java.util.Properties;

/**
 * @author 橘柚
 * @version 1.0-SNAPSHOT
 * @Date 2024/7/20 15:16
 * @Description Druid数据源工厂
 */
public class DruidJvyouDataSourceFactory implements JvyouDataSourceFactory {
    @Override
    public DataSource getDataSource(Properties properties) {
        DruidDataSource dataSource = null;
        try {
            dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        System.out.println("maxActive:" + dataSource.getMaxActive());
        System.out.println("initialSize:" + dataSource.getInitialSize());
        return dataSource;
    }
}
